OPENSSL100_INCLUDE_PATH = /usr/local/ssl/include
CURL_WITH_CARES_INCLUDE_PATH = /usr/local/include

OPENSSL100_LIB_PATH = /usr/local/ssl/lib
CURL_WITH_CARES_LIB_PATH = /usr/local/lib


COMPILE.CPP = g++
CPPFLAGS = $(WARNINGS.CPP) $(INCLUDE)

WARNINGS.CPP = -Wall -Werror -Wsynth -Wcast-qual -fdiagnostics-show-option
INCLUDE =  -I$(OPENSSL100_INCLUDE_PATH) -I$(CURL_WITH_CARES_INCLUDE_PATH) -I./include -I./libs/include -I.

OPENMP = -fopenmp
PTHREAD = -lpthread
DONTLINK = -c

DEBUG = -g -O0 -fno-inline
OPTIMIZE = -O2
TEST = -DTESTING

all: CPPFLAGS += $(OPTIMIZE)
all: NAME = scrw
all: scrw

debug: CPPFLAGS += $(DEBUG)
debug: NAME = scrw
debug: scrw

test: CPPFLAGS += $(TEST)
test: NAME = scrw_test
test: scrw
	./$(NAME)

scrw: gtest.o main.o openssl_init.o
	$(COMPILE.CPP) $(CPPFLAGS) $(OPENMP) $(PTHREAD) -o$(NAME) $^ -lz -L$(OPENSSL100_LIB_PATH) -lssl -lcrypto -L$(CURL_WITH_CARES_LIB_PATH) -lcurl -licudata -licuuc -licui18n -licule -liculx -licutu

gtest.o: gtest/gtest-all.cc
	$(COMPILE.CPP) $(CPPFLAGS) $(DONTLINK) $(OPENMP) $(PTHREAD) -o$@ $^

main.o: src/main.cc
	$(COMPILE.CPP) $(CPPFLAGS) $(DONTLINK) $(OPENMP) $(PTHREAD) -o$@ $^

openssl_init.o: src/openssl_init.cc
	$(COMPILE.CPP) $(CPPFLAGS) $(DONTLINK) $(PTHREAD) -o$@ $^

clean:
	rm -f *.o


